package com.woniuxy.controller;

import com.woniuxy.controller.entity.User;
import org.springframework.web.bind.annotation.*;

/**
 * @BelongsProject: java-85-course-code
 * @BelongsPackage: com.woniuxy.controller
 * @Author: LiTongMiao
 * @Date: 2022/1/25 17:05
 * @Description: TODO
 */
@RestController
//通常是用于restful风格写法
public class UserRestFulController {
  @RequestMapping(value = "/user",method = RequestMethod.POST)
  public String addUser(@RequestBody User user){
    System.out.println("userrestfulcontroller.adduser方法");
    return user.toString();
  }
  @DeleteMapping("/user/{id}/{userid}/{myname}")
  public String deleteUser(@PathVariable("userid")int id,@PathVariable("id")int userid,@PathVariable String myname){
    System.out.println("UserResFulController.deleteUser执行");
    return id+"____"+userid+"___"+myname;
  }
  @PutMapping("/user")
  public String updateUser(@RequestBody User user) {
      System.out.println("UserRestFulController.updateUser执行");
      return user.toString();

  }
  @GetMapping("/user/{id}")
  public String findUser(@PathVariable("id") int userid){
    System.out.println("UserResFulContrroller.findUser:"+userid);
    User user = new User(userid+"",userid);
    return user.toString();
  }
}
